<?php
/**
Exibe as informa��es que foram inseridas no formul�rio de cadastro de Reserva
Ap�s confirmada, as informa��es ser�o inseridas no banco de dados.
*/

if( !function_exists('__autoload') )
{
    function __autoload($class_name) {
    require_once $class_name . '.php';
    }
}


// dados do formulário vindos de CadastrarRateio.php
$reservaId = $_GET['idReserva'];

$reservaDao = new Reserva();
$reserva = $reservaDao->CarregarReserva($reservaId);

function montaMascara($msg="", $mask="") {
        $cMask = $mask;
        $cMsg = $msg;
        //refaz máscara
        for($i=0;$i<=strlen($cMask)-1;$i++)
            if(strlen($cMsg)-1 >= $i) //verifica se existe tantos caracteres

                if($cMask[$i] != "#" && $cMsg[$i] != $cMask[$i]) {
//Verifica se o caracter da máscara é especial, se for verifica se é igual

                    $nMsg = ""; //Cria nova mensagem
                    for($b=0;$b<=strlen($cMsg)-1;$b++) //refaz mensagem
                        if($b==$i) $nMsg = $nMsg.$cMask[$i].$cMsg[$b]; //Se


                        else $nMsg = $nMsg.$cMsg[$b];
                    $cMsg = $nMsg;
                }

        return $nMsg;
} 

?>
<html>
           <head>
           <title>SAEO - Consulta de Reserva </title>
           <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
           <link rel='stylesheet' type='text/css' href='templates/estilos.css'>
           </head>
     		<body class='body'>
     		<form name='confirmar_reserva' action='EnviarDadosReserva.php?operacao=4' method='post'>
     		<table width='779' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
            <input name='reservaId' type="hidden" />
            <tr>
				<td><?php include "Topo.php"; ?> </td>
			</tr>
            <tr>
                <td><div class='titulosTabelas' style='width:779; height:20; background:url(templates/tabela.jpg)'>CONSULTA DE RESERVA ORÇAMENTÁRIA</div></td>
            </tr>
            <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
            <tr>
            	
                <td><table class='tabela' width='650' border='0' cellspacing='0' cellpadding='0' align='center' bgcolor='#FFFFFF'>
                           <tr>
                               <td>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas' width='30%'>&nbsp;Ano:</td>
                               <td class='textoTabelas'><?php echo $reserva->ano->ano; ?></td>
                           </tr>
                           <tr>
                               <td>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas' width='30%'>&nbsp;A&ccedil;&atilde;o Or&ccedil;ament&aacute;ria:</td>
                               <td class='textoTabelas'><?php echo $reserva->rateio->fonte->programa->nome; ?></td>
                           </tr>
                           <tr>
                               <td>&nbsp;</td>
                           </tr>                           
                           <tr>
                               <td class='textoTabelas' width='30%'>&nbsp;Tipo de Despesa:</td>
                               <td class='textoTabelas'><?php echo ($reserva->tipoDespesa == 33)?"33 - Corrente" : "44 - Capital" ?></td>
                           </tr>                           
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Unidade:</td>
                               <td class='textoTabelas'><?php echo $reserva->campus->nome; ?></td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Programa:</td>
                               <td class='textoTabelas'><?php echo $reserva->rateio->fonte->programa->nomePrograma->nome; ?></td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Setor:</td>
                               <td class='textoTabelas'><?php echo $reserva->setor->nome; ?></td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Processo:</td>
                               <td class='textoTabelas'><?php echo montaMascara($reserva->processo,"#####.######/####-##"); ?></td>
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Modalidade Licitacao:</td>
                               <td class='textoTabelas'><?php echo $reserva->licitacao->sigla." - ".$reserva->licitacao->modalidade; ?></td>
                               
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Despesa:</td>
                               <td class='textoTabelas'><?php echo $reserva->despesa; ?></td>
                               
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Natureza de Depesa:</td>
                               <td class='textoTabelas'><?php echo $reserva->naturezaDespesa->id." - ".$reserva->naturezaDespesa->descricao; ?> 
                               </td>
                               
                               
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Subelemento:</td>
                               <td class='textoTabelas'><?php echo $reserva->subElemento->subElementoId." - ".$reserva->subElemento->descricao; ?> 
                               </td>
                               
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>
                           <tr>
                               <td class='textoTabelas'>&nbsp;Data da Reserva:</td>
                               <td class='textoTabelas'><?php echo $reserva->data; ?> 
                               </td>
                               
                           </tr>
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>                                                                                                                                       
                           <tr>
                               <td class='textoTabelas'>&nbsp;Valor da Reserva:</td>                               
                               <td class='textoTabelas'>R$&nbsp;<?php echo number_format($reserva->valor/100,2, ',', '.'); ?></td>
                               
                           </tr>                           
                           <tr>
                               <td colspan='2'>&nbsp;</td>
                           </tr>                           
                           <tr>
                               <td colspan='2' height='46'><div style='position:relative;left:220px'><img style='width:100px;height:30px;cursor:pointer;' src='templates/btcancelar.png' onclick='javascript: history.go(-1);'>&nbsp
                               <a href="reports/RelDespachoOrcamento.php?reservaId=<?php echo $reservaId; ?>&disponibilidade=sim"><input type='image' style='width:100px;height:30px;' src='templates/btimprimir.png'/></a></div></td>
                           <tr>
                     </table>
                </td>
            </tr>
            <tr>
                <td>&nbsp;</td>
            </tr>
            <tfoot>
           <tr>
                <td colspan='2'>&nbsp;</td>
            </tr>
                   <tr><?php include 'rodapeCreditos.php'; ?></tr>
            </tfoot>
     </table>
     </form>
     </body>
     </html>